//导航列表
let db = require("../db/index")
const videoList = (req, res) => {
    var sql = 'select * from videolist where type=?'
    db.query(sql, [req.query.type], (err, result) => {
        if (err) {
            // return res.send('错误：' + err.message)
            res.json({
                code: "0",
                msg: err.message
            });
            return
        } else {
            // res.send(result)

            res.json({
                code: "1",
                msg: "操作成功",
                result: result
            })
        }
    })
}

const rankingList = (req, res) => {
    var sql = 'SELECT * FROM videolist WHERE DATE=?'
    db.query(sql, [req.body.date], (err, result) => {
        if (err) {
            // return res.send('错误：' + err.message)
            res.json({
                code: "0",
                msg: err
            });
            return
        } else {
            // res.send(result)
            res.json({
                code: "1",
                msg: "操作成功",
                result: result
            })
        }
    })
}

const acgxq = (req, res) => {
    var sql = 'select * from videolist where id=?'
    db.query(sql, [req.body.id], (err, result) => {
        if (err) {
            res.json({
                code: "0",
                msg: err
            });
            return
        } else {
            res.json({
                code: "1",
                msg: "操作成功",
                result: result
            })
        }
    })
}
module.exports = {
    videoList, rankingList, acgxq
}